package com.heiye.quiz.biz.rpc;

import com.heiye.generator.id.generator.api.api.DistributedIdGeneratorFeignApi;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

/**
 * @author: heiye
 * @date: 2025/03/16 下午8:52
 * @version: v1.0.0
 * @description: 分布式 ID 生成服务
 */
@Component
public class DistributedIdGeneratorRpcService {
    @Resource
    private DistributedIdGeneratorFeignApi distributedIdGeneratorFeignApi;

    /**
     * Leaf 号段模式：用户 ID 业务标识
     */
    private static final String BIZ_TAG_QUIZ_ID = "leaf-segment-quiz-id";

    /**
     * 生成雪花算法 ID
     *
     * @return
     */
    public String getSnowflakeId() {
        return distributedIdGeneratorFeignApi.getSnowflakeId("test");
    }

    /**
     * 调用分布式 ID 生成服务问题 ID
     *
     * @return
     */
    public String getQuizId() {
        return distributedIdGeneratorFeignApi.getSegmentId(BIZ_TAG_QUIZ_ID);
    }
}
